﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string activeMenuButtonID = (string)Session["ActiveMenuButton"];

        if (activeMenuButtonID == null) return;
            //activeMenuButtonID = "menuButton1";
        
        LinkButton activeMenuButton = (LinkButton)FindControl("menuPlaceHolder").FindControl(activeMenuButtonID);
        if (activeMenuButton != null)
        {
            activeMenuButton.BackColor = Color.FromArgb(114, 0, 172);
            activeMenuButton.ForeColor = Color.White;
        }

        Session["ActiveMenuButton"] = null;
    }

    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        LinkButton lb = (LinkButton)sender;
        Session["ActiveMenuButton"] = lb.ID;
        Response.Redirect(lb.CommandArgument);
    }

    protected void toolbarButton_Command(object sender, CommandEventArgs e)
    {
        if (e.CommandName.ToLower().Equals("redirect".ToLower()))
        {
            Response.Redirect((String)e.CommandArgument);
        }
    }
}
